#define _CRT_SECURE_NO_WARNINGS 1

#include "HashTable.h"



template<class K, class Hash =  HashFunc<K>>
class unordered_set
{	
	struct SetKeyOfT
	{
		const K& operator()(const K& key)
		{
			return key;
		}
	};
public:
	typedef typename hash_bucket::HashTable<K, const K, SetKeyOfT, Hash>::iterator iterator;
	typedef typename hash_bucket::HashTable<K, const K, SetKeyOfT, Hash>::const_iterator const_iterator;

	pair<iterator, bool> insert(const K& key)
	{
		return _ht.Insert(key);
	}

	iterator begin()
	{
		return _ht.begin();
	}

	iterator end()
	{
		return _ht.end();
	}
	const_iterator begin()const
	{
		return _ht.begin();
	}

	const_iterator end()const
	{
		return _ht.end();
	}

	iterator find(const K& key)
	{
		return _ht.Find(key);
	}
	bool erase(const K& key)
	{
		return _ht.Erase(key);
	}



private:
	hash_bucket::HashTable<K,const K, SetKeyOfT, Hash> _ht;
};

void Func(const unordered_set<int>& s)
{
	unordered_set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		//*it = 1;
		cout << *it << " ";
		++it;
	}
}

void test_unordered_set()
{
	unordered_set<int> s;
	s.insert(1);
	s.insert(11);
	s.insert(4);
	s.insert(3);
	s.insert(51);
	s.insert(18);
	s.insert(9);

	unordered_set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		//*it = 1;
		cout << *it << " ";
		++it;
	}
	cout << endl;

	for (auto e : s)
	{
		cout << e << " ";
	}
	cout << endl;
}